/**
 * 
 */
package com.shine.icis.dao.imp;

import java.util.List;

import org.hibernate.Query;

import com.shine.icis.dao.IETLContextVarDAO;
import com.shine.icis.dao.imp.BaseHibernateDAO;
import com.shine.icis.hbean.ETLContextVar;

/**
 * @author zsy
 *
 */
public class ETLContextVarDAO extends BaseHibernateDAO implements IETLContextVarDAO {
	
	@Override
	public ETLContextVar findById(String id) {
		ETLContextVar cfg = (ETLContextVar)getSession().get(ETLContextVar.class, id);
		return cfg;
	}
	
	@Override
	public ETLContextVar findByName(String varName) {
		Query query = getSession().createQuery("from ETLContextVar as var where var.varName=:varName");
		query.setString("varName", varName);
    	query.setMaxResults(1);
    	return (ETLContextVar)query.uniqueResult();
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<ETLContextVar> findAll() {
		String hql = "from ETLContextVar as var";
    	Query query = getSession().createQuery(hql);
    	return query.list();
    }
}
